<?php
/**
 * Created by PhpStorm.
 * User: chenshiqi
 * Date: 2018/9/11
 * Time: 17:28
 */

namespace app\common\model;

/**
 * 好友模型类
 */
class Friend extends Common
{
    /**
     * 查询好友
     * @param $user_id
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function getFriendDetail($user_id)
    {
        return $this->alias('f')
                    ->join(['chat_user'=>'u'],'f.friend_id = u.id')
                    ->join(['chat_friend_group'=>'fg'],'fg.id = f.group_id')
                    ->where(['f.user_id'=>$user_id])
                    ->field('u.id,u.username,u.status,u.sign,u.avatar,fg.groupname,f.group_id')
                    ->select();
    }
}